package control;

import service.UserService;
import vo.Users;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet("/user_update.action")
public class UserUpdateControl extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        UserService service = UserService.getInstance();
        Users user = service.queryUserById(Integer.parseInt(id));

        request.setAttribute("user", user);
        request.getRequestDispatcher("/user_add.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}